package com.lihuu.easytext.analysis.cli;

import com.lihuu.easytext.analysis.api.Analyzer;
import com.lihuu.easytext.analysis.api.Fast;

import java.util.ServiceLoader;
import java.util.stream.Collectors;

/**
 * @author lihu <1449488533qq@gmail.com>
 * @since 2021/5/5 21:06
 */
public class Main {
    public static void main(String[] args) {
        ServiceLoader.load(Analyzer.class)
            .stream().filter(provider -> isFast(provider.type()))
            .map(ServiceLoader.Provider::get).collect(Collectors.toList())
            .forEach(analyzer -> System.out.println(analyzer.getName()));
    }

    private static boolean isFast(Class<? extends Analyzer> cls) {
        return cls.isAnnotationPresent(Fast.class) && cls.getAnnotation(Fast.class).value();
    }
}
